import 'package:aihu_getx_app/app/modules/commons/commons.dart';
import 'package:aihu_getx_app/app/routes/app_pages.dart';
import 'package:aihu_getx_app/utils/constants.dart';
import 'package:aihu_getx_app/widgets/common_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../controllers/d_my_controller.dart';

class DMyView extends GetView<DMyController> {
  const DMyView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Commons.appBar(
        title: controller.title,
        subTitle: controller.appName.value,
        refresh: controller.onRefresh,
      ),
      body: Container(
        color: Colors.white,
        width: Get.width,
        height: Get.height,
        padding: const EdgeInsets.all(10),
        child: Obx(
          () => RefreshIndicator(
            color: Get.theme.primaryColorLight,
            backgroundColor: Get.theme.primaryColor,
            onRefresh: controller.onRefresh,
            child: ListView(
              children: [
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        CommonImage(
                          GetUtils.isNullOrBlank(
                                  controller.userProfile.value.avatar)!
                              ? Constants.icon
                              : controller.userProfile.value.avatar,
                          width: 100,
                          height: 100,
                          isCircle: true,
                        ),
                        const SizedBox(width: 10),
                        Expanded(
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(
                                '${controller.userProfile.value.nickname}',
                                style: Get.textTheme.titleLarge,
                              ),
                              Text(
                                'ID: ${controller.userProfile.value.id ?? ''}',
                                style: Get.textTheme.bodySmall,
                              ),
                              Text(
                                '手机号: ${controller.userProfile.value.mobile ?? ''}',
                                style: Get.textTheme.bodySmall,
                              ),
                              Text(
                                '登录账号: ${controller.userProfile.value.username ?? ''}',
                                style: Get.textTheme.bodySmall,
                              ),
                            ],
                          ),
                        ),
                        // const Icon(
                        //   Icons.qr_code,
                        // ),
                        const Icon(
                          Icons.keyboard_arrow_right,
                        ),
                      ],
                    ),
                  ),
                  onTap: () => Get.toNamed(Routes.dMyProfileDetail),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                ListTile(
                  leading: const Icon(
                    Icons.qr_code,
                  ),
                  title: Text(
                    '我的工卡',
                    style: Get.textTheme.titleMedium,
                  ),
                  trailing: const Icon(
                    Icons.keyboard_arrow_right,
                  ),
                  onTap: () => Get.toNamed(Routes.dMyUserJobCard),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                ListTile(
                  leading: const Icon(
                    Icons.wechat_outlined,
                  ),
                  title: Text(
                    '社交信息',
                    style: Get.textTheme.titleMedium,
                  ),
                  trailing: const Icon(
                    Icons.keyboard_arrow_right,
                  ),
                  // onTap: () => Get.toNamed(Routes.dMyProfile),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                ListTile(
                  leading: const Icon(
                    Icons.lock_clock_outlined,
                  ),
                  title: Text(
                    '修改密码',
                    style: Get.textTheme.titleMedium,
                  ),
                  trailing: const Icon(
                    Icons.keyboard_arrow_right,
                  ),
                  // onTap: () => Get.toNamed(Routes.dMyProfile),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                ListTile(
                  leading: const Icon(
                    Icons.power_settings_new_rounded,
                  ),
                  title: Text(
                    '退出登录',
                    style: Get.textTheme.titleMedium,
                  ),
                  trailing: const Icon(
                    Icons.keyboard_arrow_right,
                  ),
                  onTap: () => controller.logout(),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
